#!/bin/bash

source /home/shell/util.sh



# 安装函数
function install () {
    requireJava
    source /etc/profile.d/java.sh
    
    hbase_file_name=$(curl -sL https://mirrors.tuna.tsinghua.edu.cn/apache/hbase/stable/|grep -Po "hbase-\d+\.\d+\.\d+-bin.tar.gz"|uniq)
    hbase_client_file_name=$(curl -sL https://mirrors.tuna.tsinghua.edu.cn/apache/hbase/stable/|grep -Po "hbase-\d+\.\d+\.\d+-client-bin.tar.gz"|uniq)

    download /opt/hbase.tar.gz https://mirrors.tuna.tsinghua.edu.cn/apache/hbase/stable/${hbase_file_name}
    tar -xf /opt/hbase.tar.gz -C /opt/
    mv /opt/hbase-* /opt/hbase


    download /opt/hbase-client-bin.tar.gz https://mirrors.tuna.tsinghua.edu.cn/apache/hbase/stable/${hbase_client_file_name}
    tar -xf /opt/hbase-client-bin.tar.gz -C /opt/
    mv /opt/hbase-*-client /opt/hbase-client

    rm -rf /opt/hbase.tar.gz
    rm -rf /opt/hbase-client-bin.tar.gz
}

# 配置函数
function config(){
    echo 'config';
}

function run () {
    echo 'run';
}

# 运行安装和配置
install && config